<%-- 
    Document   : searchbox
    Created on : Oct 4, 2011, 1:31:42 PM
    Author     : WMThiet
--%>

<%@page pageEncoding="UTF-8"%>
<%@page import="pojo.SanPhamPOJO"%>
<%
    float[] listMinPrice = new float[4];
    listMinPrice[0] = 2000000;
    listMinPrice[1] = 4000000;
    listMinPrice[2] = 6000000;
    listMinPrice[3] = 8000000;
    
    float[]  listMaxPrice = new float[6];
    listMaxPrice[0] = 10000000;
    listMaxPrice[1] = 20000000;
    listMaxPrice[2] = 30000000;
    listMaxPrice[3] = 50000000;
    listMaxPrice[4] = 80000000;
    listMaxPrice[5] = 120000000;
    
    float giaMin = 1;
    if(request.getParameter("priceMin") != null){
        giaMin = Float.parseFloat(request.getParameter("priceMin"));
    }
    float giaMax = 1;
    if(request.getParameter("priceMax") != null){
        giaMin = Float.parseFloat(request.getParameter("priceMax"));
    }
%>

<div class='sidebar_box' id='search_adv_box'> 
    <h3>Tìm kiếm nâng cao</h3> 
    <div class='content_box'> 
        <form action='ketquatimkiem.tv' method='get'> 
            <div class='label_row'>Từ khóa</div> 
            <div class='value_row'><input type='text' id='keyword' name='key' /></div> 
            <div class='label_row'>Danh mục</div> 
            <div class='value_row'> 
                <select name='cat'> 
                    <option selected='selected' value='-1'>Tất cả danh mục</option> 
                    <%if(dsDanhMuc != null && dsDanhMuc.isEmpty() == false){
                            for(int i = 0; i < dsDanhMuc.size(); i ++){%>
                            <option value='<%=dsDanhMuc.get(i).getMaDanhMuc()%>'><%=dsDanhMuc.get(i).getTenDanhMuc()%></option>
                        <%}
                    }%>
                </select> 
            </div> 
            <div class='label_row'>Giá từ</div>   
            <div class='value_row'> 
                <select name='priceMin'> 
                    <%for(int i = 0; i < listMinPrice.length; i ++){
                        if(listMinPrice[i] == giaMin){%>
                            <option value="<%=listMinPrice[i]%>" selected="selected"><%=SanPhamPOJO.customFormat("###,###",listMinPrice[i])%> VNĐ</option>
                        <%}else{%>
                        <option value="<%=listMinPrice[i]%>"><%=SanPhamPOJO.customFormat("###,###",listMinPrice[i])%> VNĐ</option>
                        <%}%>
                    <%}%>
                </select> 
            </div> 
            <div class='label_row'>Giá đến</div>   
            <div class='value_row'> 
                <select name='priceMax'> 
                    <%for(int i = 0; i < listMaxPrice.length; i ++){
                        if(listMaxPrice[i] == giaMax){%>
                            <option value="<%=listMaxPrice[i]%>" selected="selected"><%=SanPhamPOJO.customFormat("###,###",listMaxPrice[i])%> VNĐ</option>
                        <%}else{%>
                            <option value="<%=listMaxPrice[i]%>"><%=SanPhamPOJO.customFormat("###,###",listMaxPrice[i])%> VNĐ</option>
                        <%}%>
                    <%}%>
                </select> 
            </div> 
            <input type='hidden' value='1' name='page'/>
            <p><input class='btn_orange' type='submit' value='Xem kết quả'/> </p> 
        </form>                                           
    </div> 
    <!-- kết thúc content_box--> 
</div> 
<!-- kết thúc sidebar_box--> 